home *** CD-ROM | disk | FTP | other *** search
/ Ham Radio 2000 #2 / Ham Radio 2000 - Volume 2.iso / HAMV2 / MISC / HCAL-27 / JCALC.BAS (.txt) < prev    next >
Encoding:
GW-BASIC  |  1997-03-24  |  3.6 KB  |  139 lines

  1. 10  'JCALC - "J-Calculator" - 24 MAR 97 rev.
  2. 20  IF EX$=""THEN EX$="EXIT"
  3. 30  CLS:KEY OFF
  4. 40  COLOR 7,0,1
  5. 50  U$="######.#"
  6. 60  UL$=STRING$(80,205)
  7. 70  GOTO 140
  8. 80  '
  9. 90  '.....format
  10. 100  LOCATE CSRLIN-1:PRINT SPC(7);
  11. 110  LOCATE CSRLIN,47:PRINT STRING$(7,".");USING U$;ZZ;
  12. 120  RETURN
  13. 130  '
  14. 140  '.....start
  15. 150  CLS:COLOR 15,2
  16. 160  PRINT " J-CALCULATOR  (Complex Impedances)";
  17. 170  PRINT TAB(57)"by N. Sutherland ZL2APG ";
  18. 180  PRINT STRING$(80,32);
  19. 190  LOCATE CSRLIN-1,12
  20. 200  PRINT " edited and enhanced for HAMCALC by George Murphy VE3ERP"
  21. 210  COLOR 1,0:PRINT STRING$(80,223);:COLOR 7,0
  22. 220  GOSUB 960    'preface
  23. 230  COLOR 0,7:LOCATE 25,24
  24. 240  PRINT " Press 1 to continue or 0 to EXIT ";:COLOR 7,0
  25. 250  Z$=INKEY$:IF Z$=""THEN 250
  26. 260  IF Z$="0"THEN CLS:RUN EX$
  27. 270  IF Z$="1"THEN 300
  28. 280  GOTO 250
  29. 290  '
  30. 300  '.....inputs
  31. 310  VIEW PRINT 4 TO 24:CLS:VIEW PRINT:LOCATE 5
  32. 320  PRINT " 1st IMPEDANCE (Z1)"
  33. 330  INPUT " ENTER: Resistive Component....................(ohms)";A
  34. 340  ZZ=A:GOSUB 90:PRINT " -"
  35. 350  INPUT " ENTER: Reactive  Component....................(ohms)";B
  36. 360  ZZ=B:GOSUB 90:PRINT " -"
  37. 370  IF B<0 THEN J$="-j"ELSE J$="+j"
  38. 380  B$=STR$(B):B$=RIGHT$(B$,LEN(B$)-1)
  39. 390  PRINT "         Z1 Complex Impedance =";A;J$;B$;" -"
  40. 400  PRINT
  41. 410  PRINT " 2nd IMPEDANCE (Z2)
  42. 420  INPUT " ENTER: Resistive Component....................(ohms)";C
  43. 430  ZZ=C:GOSUB 90:PRINT " -"
  44. 440  INPUT " ENTER: Reactive  Component....................(ohms)";D
  45. 450  ZZ=D:GOSUB 90:PRINT " -"
  46. 460  IF D<0 THEN J$="-j"ELSE J$="+j"
  47. 470  D$=STR$(D):D$=RIGHT$(D$,LEN(D$)-1)
  48. 480  PRINT "         Z2 Complex Impedance =";C;J$;D$;" -"
  49. 490  LN=CSRLIN:PRINT UL$;
  50. 500  FOR I=1 TO 4:ON I GOSUB 660,720,780,840:NEXT I:GOTO 900
  51. 510  VIEW PRINT LN TO 24:CLS:VIEW PRINT:LOCATE LN+1
  52. 520  IF X<0 THEN J$=" -j"ELSE J$=" +j"
  53. 530  Z=INT(Z*10^3+0.5)/10^3
  54. 540  Z$=RIGHT$(STR$(Z),LEN(STR$(Z))-1)
  55. 550  IF ABS(Z)>0 AND ABS(Z)<1 THEN Z$="0"+Z$
  56. 560  IF Z<0 THEN Z$="-"+Z$ ELSE Z$=" "+Z$
  57. 570  X=INT(X*10^3+0.5)/10^3
  58. 580  X$=RIGHT$(STR$(X),LEN(STR$(X))-1)+" - "
  59. 590  IF ABS(X)>0 AND ABS(X)<1 THEN X$="0"+X$
  60. 600  PRINT TAB(9)"RESULT:";
  61. 610  PRINT " Z1 "R$" Z2";STRING$(30,".");
  62. 620  COLOR 0,7:PRINT " "Z$;J$;X$:LN=CSRLIN
  63. 630  COLOR 7,0
  64. 640  RETURN
  65. 650  '
  66. 660  '.....add
  67. 670  Z=A+C
  68. 680  X=B+D
  69. 690  R$="+"
  70. 700  GOTO 510
  71. 710  '
  72. 720  '.....subtract
  73. 730  Z=A-C
  74. 740  X=B-D
  75. 750  R$="-"
  76. 760  GOTO 510
  77. 770  '
  78. 780  '.....multiply
  79. 790  Z=(A*C)-(B*D)
  80. 800  X=(A*D)+(B*C)
  81. 810  R$="x"
  82. 820  GOTO 510
  83. 830  '
  84. 840  '.....divide
  85. 850  Z=((A*C)+(B*D))/(C^2+D^2)
  86. 860  X=((B*C)-(A*D))/(C^2+D^2)
  87. 870  R$="<UNK! {00F6}>"
  88. 880  GOTO 510
  89. 890  '
  90. 900  '.....end
  91. 910  PRINT :COLOR 0,7
  92. 920  LOCATE ,27:PRINT " Press any key to continue ";:COLOR 7,0
  93. 930  IF INKEY$=""THEN 930
  94. 940  GOTO 140
  95. 950  '
  96. 960  '.....preface
  97. 970  T=7
  98. 980  PRINT TAB(T);
  99. 990  PRINT "  This program is intended as a j calculator for the addition,"
  100. 1000  PRINT TAB(T);
  101. 1010  PRINT "subtraction, multiplication and division of impedances in"
  102. 1020  PRINT TAB(T);
  103. 1030  PRINT "rectangular form (happily, without switching back and forth from"
  104. 1040  PRINT TAB(T);
  105. 1050  PRINT "rectangular to polar form). There is never any doubt which quadrant"
  106. 1060  PRINT TAB(T);
  107. 1070  PRINT "you are in."
  108. 1080  PRINT TAB(T);
  109. 1090  PRINT "  For those of you who have not used operator j lately, +j rotates"
  110. 1100  PRINT TAB(T);
  111. 1110  PRINT "the impedance vector from the 3 o'clock initial position anti-"
  112. 1120  PRINT TAB(T);
  113. 1130  PRINT "clockwise 90<UNK! {00F8}> to the 12 o'clock position, and -j rotates from the"
  114. 1140  PRINT TAB(T);
  115. 1150  PRINT "3 o'clock initial position to 6 o'clock. As anyone can plainly see,"
  116. 1160  PRINT TAB(T);
  117. 1170  PRINT "+j is inductive and -j is capacitive. If this you cannot plainly"
  118. 1180  PRINT TAB(T);
  119. 1190  PRINT "see, don't bother about it; j has been used for 200 years without"
  120. 1200  PRINT TAB(T);
  121. 1210  PRINT "anyone knowing how it works."
  122. 1220  PRINT TAB(T);
  123. 1230  PRINT "  It is no longer necessary to grapple with the Complex Algebra"
  124. 1240  PRINT TAB(T);
  125. 1250  PRINT "section of the 1997 ARRL HANDBOOK for RADIO AMATEURS (p.4.15), or"
  126. 1260  PRINT TAB(T);
  127. 1270  PRINT "other reference works of similar ilk. Use this program instead, to"
  128. 1280  PRINT TAB(T);
  129. 1290  PRINT "avoid boggling your mind."
  130. 1300  PRINT TAB(T);
  131. 1310  PRINT
  132. 1320  PRINT TAB(T);
  133. 1330  PRINT "  The original version of this program was published in Vol. 70, #1"
  134. 1340  PRINT TAB(T);
  135. 1350  PRINT "of BREAK-IN, the official journal of the New Zealand Association"
  136. 1360  PRINT TAB(T);
  137. 1370  PRINT "of Radio Transmitters Inc.";
  138. 1380  RETURN
  139.